Many business or enterprise systems make use of applications that reference data objects, or units of data with rules regarding access/manipulation of the data. Data objects, or simply objects, as referred to herein should be understood to include any type of data object, including business objects, which are objects referenced by a business application or software executing a business process. In many implementations, one or more objects are shared by multiple applications.
An application may be part of a virtual machine (VM) that includes one or more applications. The applications of a VM can access functionality across multiple platforms and systems accessible from the VM. The applications typically have a local memory, which may be accessible through the VM. In addition to a local memory, the applications have access to a shared memory. The shared memory may serve to store or cache commonly used objects or objects shared among multiple applications.
Particular implementations of enterprise systems include the use of a mappable shared closure, which provides a data structure in shared memory to store one or more objects, including a tree of related objects. A shared closure includes an object and all objects transitively reachable from the object. Shared closures exist in shared memory, and can be copied locally to the local memories for operation on one or more objects or object relationships (references). Traditional management of the shared memory encounters problems when dealing with shared closures. In short, the creation, copying, and/or modifying of a shared closure may introduce errors into a system that may not be detectable for months or longer. Traditional management of shared closures failed to fully appreciate the behavior of the shared closures in using and/or referencing objects. Problems associated with known methods of object management are discussed in more detail below with reference to FIG. 1.
FIG. 1 is a block diagram of a prior art embodiment of a mappable shared memory having shared closures. Local memories 110 and 120 represent memory local to one or more applications or a VM having the application. Local memories 110 and 120 may be the same or separate memories. Mappable shared memory 130 includes multiple shared closures. In practice, shared closures may be restricted to being mappable (can be referenced), or read-only. Referencing mappable shared closures generates the circumstances described below. Three problems to be discussed are: eviction, referencing outdated objects, and modifying read-only objects.
Regarding object eviction, management of mappable shared memory 130 can be performed by a cache management library (CML) or other management entity. A CML may have rules to evict entries from mappable shared memory 130 when the size reaches a threshold. To apply eviction, the CML will execute an eviction policy (e.g., a least recently used (LRU) policy to evict entries that have not been accessed for the longest time). Thus, if closure A is the least recently used entry, it may get evicted, without any problems presented. However, consider a circumstance such as that shown with regards to closures B and C. Closure C is created by having objects organized in a logical structure. One of the objects has a reference to shared object BC of mappable shared memory 130. Thus, objects are operated on locally within local memory 110, but with reference to a shared object stored in mappable shared memory 130. Closure C is then created in mappable shared memory 130 as the logical structure is saved, and the local object at the top of the tree is saved into mappable shared memory 130, along with all transitively reached objects of the object. As used herein, description will be made to referencing objects, referencing closures, or referencing from a closure. Terminology related to referencing a closure or referencing from a closure is understood to refer to a reference from an object of one shared closure to an object of another shared closure.
References between shared closures may render eviction useless. Consider that closure B is the entry that is determined to be evicted based on the eviction policy. The CML will attempt to evict closure B, and then apply memory management as if the memory occupied by closure B has been freed. However, a garbage collector routine may be unable to free the memory occupied by closure B because it is still referenced from closure C. The fact that the garbage collector cannot free the memory results in a discrepancy between the memory management and the real usage of memory 130. The real usage of memory 130 may in fact be higher than what the memory management indicates, which may lead to out-of-memory problems.
Regarding referencing outdated objects, an application may copy closure D to perform a modification of object DE of the closure. The copy operation results in a copy of the objects of closure D residing in local memory 120, where modification of object DE results in the object of closure D referencing object D′ in place of object DE (D′ merely being the modification of object DE). The application may then create closure D′ in mappable shared memory 130 by storing the objects (i.e., the entire data structure) from local memory 120 into shared memory 130. Thus, a new version of closure D, closure D′, exists in mappable shared memory 130. However, note that closure E references object DE of closure D. The copying and modification of object DE in local memory 110 traditionally does not modify references to the modified object even if the object itself is validly modified. Attempting to update and maintain consistency in object references for all objects copied and modified would be very difficult at best, and may be practicably unreasonable.
The update of closure D to closure D′ may lead to two separate problems. The first is that the reference from closure E to object DE of closure D would be a reference to an outdated object. Unless the same application that references object DE from closure E were the application modifying object DE, there may be no way of detecting the fact that closure E references an outdated object. Additionally, the modification and copying of closure D′ into mappable shared memory 130 would be expected to replace closure D. Thus, closure D is shown crossed out, which is the condition that would be assumed by the memory management. However, the reference to the outdated object may prevent a garbage collector from actually removing closure D, resulting in the system having a higher memory usage than expected by the memory management.
Regarding modifying read-only objects, when implementing a shared closure, it is not necessarily easily visible from an object reference whether the referenced object is stored in a heap of a local memory, or whether it is stored in a shared closure in shared memory. For example, closure C includes a reference to object BC of closure B. If an application copies the objects of closure C into local memory 110, the application may not be able to easily discern whether the reference to object BC is a reference to an object in mappable shared memory 130 (which is in fact the case in this example), or whether the reference is to an object BC contained locally (depicted by the dashed lines within the data structure shown in local memory 110). When the application attempts to modify object BC (because it assumes BC is local and modifiable) to result in closure C′ as a modified version of closure C, the attempted modification will fail. Object BC is stored in mappable shared memory 130, and is read-only. Thus, closure C′ with modified object C′ will fail.
The above problems illustrate the potential hazards of references to items stored in a mappable shared memory. However, for many applications, it may be essential to link cache items due to the complexity of application domains and resulting object graphs. Current memory management mechanisms are insufficient for dealing with the hazards involved with referencing objects stored in mappable shared memory.